package leetcode_2401_2500;

public class LeeCode_2428 {
    public static void main(String[] args) {

    }
    private static int maxSum(int[][] grid) {
        int m = grid.length, n = grid[0].length;
        int ans = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (i + 2 < m && j + 2 < n){
                    int sum = 0;
                    for (int k = 0; k < 3; k++) {
                        sum += grid[i][j + k];
                    }
                    for (int k = 0; k < 3; k++) {
                        sum += grid[i + 2][j + k];
                    }
                    sum += grid[i + 1][j + 1];
                    ans = Math.max(ans, sum);
                }
            }
        }
        return ans;
    }
}
